package com.hxgz.commom;

public class Const {

  public static final String TOKEN_PREFIX = "token_";

  public interface RedisCacheExtime {

    int REDIS_SESSION_EXTIME = 60 * 30;//30分钟
    int REDIS_YARD_EXTIME = 60 * 5;//5分钟
    int REDIS_DATA_EXTIME = 60 * 30;//5分钟
  }

  public interface PrimeCategory {

    int WIND = 1;//风
    int WATER = 2;//水
    int ELECTRICITY = 3;//电
    int FIRE_CONTROL = 4;//消防
  }

  /**
   * 验证是否登陆
   */
  /*public static User checkUserLogin(HttpServletRequest httpServletRequest) {
    String loginToken = CookieUtil.readLoginToken(httpServletRequest);
    User user = null;
    if (StringUtils.isEmpty(loginToken)) {
      return user;
    }
    String userJsonStr = RedisPoolUtil.get(loginToken);
    user = JsonUtil.string2Obj(userJsonStr, User.class);
    if (user == null) {
      return user;
    }
    return user;
  }*/

 /* public static User checkBackUserLogin(HttpServletRequest httpServletRequest) {
    String loginToken = CookieUtil.readBackLoginToken(httpServletRequest);
    User user = null;
    if (StringUtils.isEmpty(loginToken)) {
      return user;
    }
    String userJsonStr = RedisPoolUtil.get(loginToken);
    user = JsonUtil.string2Obj(userJsonStr, User.class);
    if (user == null) {
      return user;
    }
    return user;
  }*/


  public interface AlipayCallback {

    String TRADE_STATUS_WAIT_BUYER_PAY = "WAIT_BUYER_PAY";
    String TRADE_STATUS_TRADE_SUCCESS = "TRADE_SUCCESS";

    String RESPONSE_SUCCESS = "success";
    String RESPONSE_FAILED = "failed";
  }

  public enum OrderStatusEnum {
    CANCELED(4, "已取消"),
    NO_PAY(0, "待付款"),
    PAID(1, "待发货"),
    SHIPPED(2, "已发货"),
    ORDER_SUCCESS(3, "已完成"),
    ORDER_CLOSE(5, "已关闭");


    OrderStatusEnum(int code, String value) {
      this.code = code;
      this.value = value;
    }

    private String value;
    private int code;

    public String getValue() {
      return value;
    }

    public int getCode() {
      return code;
    }

    public static OrderStatusEnum codeOf(int code) {
      for (OrderStatusEnum orderStatusEnum : values()) {
        if (orderStatusEnum.getCode() == code) {
          return orderStatusEnum;
        }
      }
      throw new RuntimeException("没有找到对应的枚举");
    }
  }

}
